#!/usr/bin/python2.6
#coding: utf8

import sys
import string

print >> sys.stderr, 'unknown...'

unhash = {
			'始##始':0,
			'末##末':0,
			'未##数':1,
			'未##串':2,
			'未##时':3,
			'未##人':4,
			'未##地':5,
			'未##它':6,
			'未##专':7,
			'未##团':8,
		};

list = [0 for i in range(9)]
matrix = [[0 for i in range(9)] for j in range(9)]

for line in sys.stdin :
	arr = line.split()
	if len(arr) != 3 :
		print >> sys.stderr, 'error field line: ', line
		continue
	word = arr[0]
	freq = int(arr[2])
	n = string.find(word, '@')
	if n == -1 :
		i = unhash[word]
		list[i] = freq
		continue
	arr = word.split('@')
	word0 = arr[0]
	word1 = arr[1]
	if not (unhash.has_key(word0) and unhash.has_key(word1)) :
#		print >> sys.stderr, 'NO: ', word0, word1
		continue
	i = unhash[word0]
	j = unhash[word1]
	matrix[i][j] = freq

for i in range(9) :
	print >> sys.stdout, list[i], "\t",

print >> sys.stdout, '\n',

for i in range(9) :
	for j in range(9) :
		print >> sys.stdout, matrix[i][j], '\t', 
	print >> sys.stdout, '\n',

print >> sys.stdout, '\n',
